<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Hello, Bootstrap Table!</title>
<!-- 最新 Bootstrap4 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
<!-- bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单，包含了 popper.min.js -->
<script src="https://cdn.staticfile.org/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js"></script>

<script src="js/functions.js"></script>
<!--    <link  th:href="@{/css/bootstrap.min.css}" rel="stylesheet">-->
<!--    &lt;!&ndash; jQuery文件。务必在bootstrap.min.js 之前引入 &ndash;&gt;-->
<!--    <script th:src="@{/js/jquery-3.2.1.min.js}"></script>-->
<!--    &lt;!&ndash; bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单，包含了 popper.min.js &ndash;&gt;-->
<!--    <script	th:src="@{/js/bootstrap.bundle.min.js}"></script>-->
<!--    &lt;!&ndash; 最新的 Bootstrap4 核心 JavaScript 文件 &ndash;&gt;-->
<!--    <script	th:src="@{/js/bootstrap.min.js}"></script>-->
<!--    &lt;!&ndash; DaterangePicker &ndash;&gt;-->
<!--    <link rel="stylesheet" type="text/css" media="all" th:href="@{/daterangepicker/daterangepicker.css}" />-->
<!--    &lt;!&ndash; BootStrapValidator &ndash;&gt;-->

<!--    <link rel="stylesheet" th:href="@{css/bootstrapValidator.min.css}">-->
<!--    <script type="text/javascript" th:src="@{js/bootstrapValidator.min.js}"></script>-->
<script type="text/javascript">
	$(document).ready(
			function(){
				$('#loginFormModal').modal();
			}
	);
	function login(){
		if(!validateRequired("loginForm","username","用户名不能为空")||
				!validateRequired("loginForm","password","密码不能为空")){
			return;
		}
		var username=$("#loginForm #username").val();
		var password=$("#loginForm #password").val();
		
		$.post("./user/login",{username:username,password:password},
				function(result){
					
					if(result.login=="yes"){
						//alert("true");
						$('#loginFormModal').modal('hide');
						if(result.redirUrl)
							location.href="user/UserList.html";
						else
							location.href="index.html";
					}
					else{
						alert("用户名或密码错误");
					}
				});
	}
</script>
</head>
<body>
<div class="modal fade" id="loginFormModal" role="dialog" aria-hidden="true" aria-labelledby="myModalLabel">
    <div class="modal-dialog">
        <div class="modal-content">
        <form class="form-signin" id="loginForm" method="post" >
            <div class="modal-header">
                <h5 class="modal-title" id="myModalLabel">用户登录</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>                   
            </div>
            <div class="modal-body">           
                    <label for="username" class="sr-only">用户名</label> 
                    <input type="text" id="username" class="form-control"
                        placeholder="用户名" required autofocus> 
                    <label for="password" class="sr-only">密码</label> 
                    <input type="password" id="password" class="form-control"
                        placeholder="密码" required>
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="button" onclick="login()" id="loginBtn">登录</button>
                <button class="btn btn-secondary" type="button" data-dismiss="modal">关闭窗口</button>                  
            </div>
        </form>
        </div>
    </div>
</div>
</body>
</html>